package com.leyou.item.mapper;


import com.leyou.common.mapper.BaseMapper;
import com.leyou.item.pojo.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BrandMapper extends BaseMapper<Brand> {

    /**
     * 新增商品分类和品牌中间表数据
     * @param ids 商品分类id集合
     * @param bid 品牌id
     * @return 新增的条数
     */

    int insertCategoryBrand(@Param("bid") Long bid, @Param("ids") List<Long> ids);

    @Delete("DELETE from tb_category_brand WHERE brand_id = #{bid}")
    void deleteCategoryBrand(@Param("bid") Long bid);

    @Select("select td.* from tb_brand td inner join tb_category_brand  tcb on tcb.brand_id=td.id where tcb.category_id=#{cid}")
    List<Brand> queryByCategoryId(@Param("cid") Long cid);
}
